package com.fmatos.amazingwallpapers.image.database;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

@Deprecated
public class DataSource {


	private static final String TAG = DataSource.class.getSimpleName();

    private SQLiteDatabase database;
	private final SQLiteOpenHelper dbHelper;
	private final Context context;

	private boolean isOpen = false;


	public DataSource(Context context, SQLiteOpenHelper dbHelper) {
        this.context = context;        
        this.dbHelper = dbHelper;
	}

	/**
	 * Opens DB, this may take a long time so you better don't call it in onCreate
	 * @throws SQLException
	 */
	public void open() throws SQLException {
		database = dbHelper.getReadableDatabase();
		isOpen = true;
	}

	public void close() {
		isOpen = false;
		dbHelper.close();
	}
	
	public boolean isOpen() {
		return isOpen;
	}

	public SQLiteDatabase getDatabase() {
		return database;
	}

	public Context getContext() {
		return context;
	}
	
	
	public String buildWhereClause(String columnName, String columnValue) {
		return columnName + "='" + columnValue + "'";
	}


}
